package demo02;

import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.ArrayList;
import java.util.List;

public class test {

    public static void main(String[] args) throws DocumentException {
        List<emp> getemp = getemp();
        System.out.println(getemp);
    }
    public static List< Dept> getDepts(  ){
        List< Dept> list=new ArrayList<>();



        return list;

    }
    public static List< emp> getemp() throws DocumentException {
        List<emp>list=new ArrayList<>();
        List<Element> elements = new SAXReader().read("emp.xml").getRootElement().elements();

        for (Element element : elements) {
            String name = element.elementText("emp-name");
            String empid = element.elementText("emp-id");
            String deptid = element.elementText("dept-id");
            String empsalary = element.elementText("emp-salary");
           list.add(new emp(name,empid,deptid,empsalary));
        }
        return list;
    }
}
